package com.yigang.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yigang.dao.ColorDao;
import com.yigang.entity.Color;
import com.yigang.service.ColorService;
import com.yigang.utils.ResultUtil;
@Service
@Transactional
public class ColorServiceImpl implements ColorService {

	@Autowired
	private ColorDao colorDao;
	@Override
	public ResultUtil selectColorList(Integer page, Integer limit, Color record) {
		PageHelper.startPage(page, limit);
		List<Color> color = colorDao.selectColorList(record);
		PageInfo<Color> pageInfo = new PageInfo<Color>(color);
		ResultUtil resultUtil = new ResultUtil();
		resultUtil.setCode(0);
		resultUtil.setCount(pageInfo.getTotal());
		resultUtil.setData(pageInfo.getList());
		return resultUtil;
	}

	@Override
	public ResultUtil deleteByPrimaryKey(Integer color_id) {
		// TODO Auto-generated method stub
		colorDao.deleteByPrimaryKey(color_id);
		return ResultUtil.ok();
	}

	@Override
	public ResultUtil insertSelective(Color record) {
		// TODO Auto-generated method stub
		colorDao.insertSelective(record);
		
		return ResultUtil.ok();
	}

	@Override
	public ResultUtil updateByPrimaryKeySelective(Color record) {
		// TODO Auto-generated method stub
		colorDao.updateByPrimaryKeySelective(record);
		return ResultUtil.ok();
	}

	@Override
	public Color selectColorById(int color_id) {
		// TODO Auto-generated method stub
		return colorDao.selectColorById(color_id);
	}

}
